//target function
static void
free_target(void * tex,void * desc)
{
	if (tex)
	{
		if (desc != (void*)DESC_HTARGET)
		{
			hge->System_Log("Error free target.Desc error.");
			return;
		}
		hge->Target_Free((HTARGET)tex);
	}
}
static PyObject *
pyTarget_Create(PyObject *self,PyObject *args)
{
	CHECK_HGE;
	int w,h;
	PyObject * zbobj=Py_False;
	if (!PyArg_ParseTuple(args,"ii|O:Target_Create",&w,&h,&zbobj))
		return 0;
	int bval = PyObject_IsTrue(zbobj);
	if (bval==-1) return 0;
	HTARGET target = hge->Target_Create(w,h,bval>0);
	if (!target)
	{
		PyErr_SetString(pyHGEError,hge->System_GetErrorMessage());
		return 0;
	}
	return PyCObject_FromVoidPtrAndDesc((void*)target,(void*)DESC_HTARGET,free_target);
}
static PyObject *
pyTarget_Free(PyObject *self,PyObject *args)
{
	CHECK_HGE;
	PyObject * obj;
	if (!PyArg_ParseTuple(args,"O:Target_Free",&obj))
		return 0;
	if (!PyCObject_Check(obj) || PyCObject_GetDesc(obj)!=DESC_HTARGET)
	{
		PyErr_SetString(PyExc_TypeError,"Target object is required.");
		return 0;
	}
	hge->Target_Free((HTARGET)PyCObject_AsVoidPtr(obj));
	PyCObject_SetVoidPtr(obj,NULL);
	Py_RETURN_NONE;
}
static PyObject *
pyTarget_GetTexture(PyObject *self,PyObject *args)
{
	CHECK_HGE;
	PyObject * obj;
	if (!PyArg_ParseTuple(args,"O:Target_Free",&obj))
		return 0;
	if (!PyCObject_Check(obj) || PyCObject_GetDesc(obj)!=DESC_HTARGET)
	{
		PyErr_SetString(PyExc_TypeError,"Target object is required.");
		return 0;
	}
	HTEXTURE tex = hge->Target_GetTexture((HTARGET)PyCObject_AsVoidPtr(obj));
	if (!tex)
	{
		PyErr_SetString(pyHGEError,hge->System_GetErrorMessage());
		return 0;
	}
	return PyCObject_FromVoidPtrAndDesc((void*)tex,(void*)DESC_HTEXTURE,NULL);
}